/**
 * 中医馆统计页面医生js
 * @author lh
 * 2016-01-15
 *
 */
/**
 * 医生数据表格属性配置
 */
$('#tcm_medicalDoctor_eCharts').css('height',orange.detailPage.getHeight());
$('#tcm_medicalDoctor_eCharts').css('width',orange.detailPage.getWidth());
	
	$('#tcm_medicalDoctor_Grid').datagrid({ 
		url:'d/doc/table',
	    singleSelect:true,
	    queryParams:{orgGuid:$("#tcmcpdetail_guid").val()},
	    rownumbers:true,
	    columns:[[ 
	        {field:'doctorName',title:'姓名',width:'10%',sortable:true,halign:'center'},
	        {field:'doctorType',title:'类型',width:'10%',sortable:true,halign:'center',formatter:function(value){
	          	var value_other = value == null ? "" : value;
	          	value_other = value_other==0?"中医医师":"西医医师";
	        	return '<span title="' + value_other + '">' + value_other + '</span>';
	        }}, 
	        {field:'licenseTypeName',title:'执照类型',width:'10%',sortable:true,halign:'center'},
	        {field:'doctorTitleName',title:'职称',width:'10%',sortable:true,halign:'center'},
	        {field:'eduBkName',title:'教育背景',width:'10%',sortable:true,halign:'center'},
	        {field:'educationName',title:'学历',width:'10%',sortable:true,halign:'center'}, 
	        {field:'age',title:'年龄',width:'8%',sortable:true,halign:'center'},
	        {field:'indate',title:'入馆时间',width:'10%',sortable:true,halign:'center'},
	        {field:'doctorStatus',title:'是否本院',width:'10%',sortable:true,halign:'center',formatter:function(value){
	          	var value_other = value == null ? "" : value;
	          	value_other = value_other==0?"在馆":"离馆";
	        	return '<span title="' + value_other + '">' + value_other + '</span>';
	        }},
	        {field:'specialityNames',title:'专长',width:'10%',sortable:true,halign:'center',formatter:function(value){
	          	var value_other = value == null ? "" : value;
	        	return '<span title="' + value_other + '">' + value_other + '</span>';
	        }}
	    ]],
	    pagination:true,
	    sortable:true,
	    sortName: 'type',
	    sortOrder: 'asc'
	});

	//echarts图表配置
	var tcm_myChart = echarts.init($("#tcm_medicalDoctor_eCharts")[0]);
	var tcm_initData
	var tcm_xData=[];
	var tcm_seriesData1=[];
	var tcm_seriesData2=[];
	$.ajax({
		url:"d/doc/chart",
		type:"get",
		data:{orgGuid:$("#tcmcpdetail_guid").val()},
		success:function(data){
			tcm_initData = JSON.parse(data)
			for (var i=0;i<tcm_initData.length;i++){
				tcm_xData.push(tcm_initData[i].period);
				tcm_seriesData1.push(tcm_initData[i].docTotal);
				tcm_seriesData2.push(tcm_initData[i].docTcm);
			}
			tcm_myChart.setOption(tcm_option);
		}
	});
	
    // 指定图表的配置项和数据
	tcm_option = {
		grid:{
			show:false,
			bottom :'15%',
			top:'25%',
			height:'65%',
			width:'80%',
			left:'10%',
			right:'15%'
		},
	    tooltip : {
	        trigger: 'axis'
	    },
	    legend: {
	        data:['医生总数','中医医生总数'],
	        top:'8%'
	    },
	    calculable : true,
	    xAxis : [
	        {
	            type : 'category',
	            boundaryGap : false,
	            data : tcm_xData//['2013-04','2013-07','2013-10','2014-01','2014-07','2014-10','2015-01','2015-04','2015-07','2015-10','2016-01']
	        }
	    ],
	    yAxis : [
	        {
	            type : 'value',
	            boundaryGap : false
	        }
	    ],
	    series : [
	        {
	            name:'中医医生总数',
	            type:'line',
	            smooth :true,
//	            stack: '总量',
	            data:tcm_seriesData2//[25,41,53,76,88,103,124,137,152,163,169,168]
	        },{
	            name:'医生总数',
	            type:'line',
	            smooth :true,
//	            stack: '总量',
	            data:tcm_seriesData1
	        }
	    ]
	};
        // 使用刚指定的配置项和数据显示图表。
	tcm_myChart.setOption(tcm_option);
